package com.yutel.interceptor;

import org.apache.struts2.interceptor.FileUploadInterceptor;
import com.opensymphony.xwork2.ActionInvocation;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;

public class JsonFileUploadInterceptor extends FileUploadInterceptor{  
    public String intercept(ActionInvocation invocation) throws Exception  {  
        String result="";  
        try {  
            result= super.intercept(invocation);  
        } catch (Exception e) {  
            HttpServletRequest request=(HttpServletRequest) invocation.getInvocationContext().get(ServletActionContext.HTTP_REQUEST);  
            HttpSession session=request.getSession();  
            session.removeAttribute("jsonUploadMsg");  
            session.setAttribute("jsonUploadMsg", "{success:false}");  
            throw e;  
        }         
        return result;  
    }  
}
